@kodiak-finance/orderly-trading-leaderboard 2.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +181 -0
- package/dist/index.d.mts +538 -0
- package/dist/index.d.ts +538 -0
- package/dist/index.js +59 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +31 -0
- package/dist/index.mjs.map +1 -0
- package/dist/styles.css +1 -0
- package/package.json +48 -0
package/README.md
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# Rewards Calculation Module
|
|
2
|
+
|
|
3
|
+
This module provides functionality for calculating estimated rewards and estimated tickets earned.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
### 1. Estimated Rewards
|
|
8
|
+
|
|
9
|
+
- Supports multiple prize pool configurations
|
|
10
|
+
- Supports different metrics based on trading volume and PnL (Profit and Loss)
|
|
11
|
+
- Supports fixed position rewards and position range rewards
|
|
12
|
+
- Automatically estimates user ranking and calculates corresponding rewards
|
|
13
|
+
|
|
14
|
+
### 2. Estimated Tickets
|
|
15
|
+
|
|
16
|
+
- Supports tiered mode: Awards different ticket amounts based on different trading volume tiers
|
|
17
|
+
- Supports linear mode: Earn Y tickets for every X trading volume
|
|
18
|
+
|
|
19
|
+
## Type Definitions
|
|
20
|
+
|
|
21
|
+
### Prize Pool Configuration
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
interface PrizePool {
|
|
25
|
+
pool_id: string; // Prize pool ID
|
|
26
|
+
label: string; // Prize pool label
|
|
27
|
+
total_prize: number; // Total prize amount
|
|
28
|
+
currency: string; // Reward currency
|
|
29
|
+
metric: "volume" | "pnl"; // Evaluation metric
|
|
30
|
+
tiers: PrizePoolTier[]; // Tier configuration
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Ticket Rules
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
interface TicketRules {
|
|
38
|
+
total_prize: number; // Total ticket prize amount
|
|
39
|
+
currency: string; // Currency
|
|
40
|
+
metric: "volume" | "pnl"; // Evaluation metric
|
|
41
|
+
mode: "tiered" | "linear"; // Mode
|
|
42
|
+
tiers?: TicketTierRule[]; // Tiered mode configuration
|
|
43
|
+
linear?: TicketLinearRule; // Linear mode configuration
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Usage Examples
|
|
48
|
+
|
|
49
|
+
### Basic Usage
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import {
|
|
53
|
+
calculateEstimatedRewards,
|
|
54
|
+
calculateEstimatedTickets,
|
|
55
|
+
CampaignConfig,
|
|
56
|
+
UserData,
|
|
57
|
+
} from "./utils";
|
|
58
|
+
|
|
59
|
+
const userdata: UserData = {
|
|
60
|
+
account_id: "user_001",
|
|
61
|
+
trading_volume: 50000,
|
|
62
|
+
pnl: 1500,
|
|
63
|
+
current_rank: 5,
|
|
64
|
+
total_participants: 1000,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const campaign: CampaignConfig = {
|
|
68
|
+
// ... campaign configuration
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// Calculate estimated rewards
|
|
72
|
+
const rewards = calculateEstimatedRewards(userdata, campaign);
|
|
73
|
+
console.log(`Estimated rewards: ${rewards?.amount} ${rewards?.currency}`);
|
|
74
|
+
|
|
75
|
+
// Calculate estimated tickets
|
|
76
|
+
if (campaign.ticket_rules) {
|
|
77
|
+
const tickets = calculateEstimatedTickets(userdata, campaign.ticket_rules);
|
|
78
|
+
console.log(`Estimated tickets: ${tickets}`);
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Usage in React Components
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
import { RewardsDesktopUI } from './rewards.desktop.ui';
|
|
86
|
+
|
|
87
|
+
function MyComponent() {
|
|
88
|
+
return (
|
|
89
|
+
<RewardsDesktopUI
|
|
90
|
+
campaign={campaignConfig}
|
|
91
|
+
userdata={userData}
|
|
92
|
+
/>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Configuration Examples
|
|
98
|
+
|
|
99
|
+
### Tiered Mode Ticket Configuration
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
ticket_rules: {
|
|
103
|
+
total_prize: 2000,
|
|
104
|
+
currency: "WIF",
|
|
105
|
+
metric: "volume",
|
|
106
|
+
mode: "tiered",
|
|
107
|
+
tiers: [
|
|
108
|
+
{ value: 25000, tickets: 10 }, // ≥ 25,000 volume → 10 tickets
|
|
109
|
+
{ value: 10000, tickets: 5 }, // ≥ 10,000 volume → 5 tickets
|
|
110
|
+
{ value: 5000, tickets: 1 } // ≥ 5,000 volume → 1 ticket
|
|
111
|
+
]
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Linear Mode Ticket Configuration
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
ticket_rules: {
|
|
119
|
+
total_prize: 1000,
|
|
120
|
+
currency: "WIF",
|
|
121
|
+
metric: "volume",
|
|
122
|
+
mode: "linear",
|
|
123
|
+
linear: {
|
|
124
|
+
every: 5000, // Every 5000 trading volume
|
|
125
|
+
tickets: 1 // Earn 1 ticket
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Prize Pool Configuration Example
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
prize_pools: [
|
|
134
|
+
{
|
|
135
|
+
pool_id: "general",
|
|
136
|
+
label: "General Pool",
|
|
137
|
+
total_prize: 10000,
|
|
138
|
+
currency: "USDC",
|
|
139
|
+
metric: "volume",
|
|
140
|
+
tiers: [
|
|
141
|
+
{ position: 1, amount: 3000 }, // 1st place: 3000 USDC
|
|
142
|
+
{ position: 2, amount: 2000 }, // 2nd place: 2000 USDC
|
|
143
|
+
{ position: 3, amount: 1000 }, // 3rd place: 1000 USDC
|
|
144
|
+
{ position_range: [4, 10], amount: 500 }, // 4th-10th place: 500 USDC each
|
|
145
|
+
{ position_range: [11, 50], amount: 100 }, // 11th-50th place: 100 USDC each
|
|
146
|
+
],
|
|
147
|
+
},
|
|
148
|
+
];
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Calculation Logic
|
|
152
|
+
|
|
153
|
+
### Ranking Estimation
|
|
154
|
+
|
|
155
|
+
The system estimates user ranking based on trading performance:
|
|
156
|
+
|
|
157
|
+
- If `current_rank` is provided, it is used directly
|
|
158
|
+
- Otherwise, a simple estimation is made based on trading volume/PnL:
|
|
159
|
+
- ≥ 100,000: Rank 1
|
|
160
|
+
- ≥ 50,000: Top 5%
|
|
161
|
+
- ≥ 10,000: Top 20%
|
|
162
|
+
- ≥ 1,000: Top 50%
|
|
163
|
+
- < 1,000: Bottom 80%
|
|
164
|
+
|
|
165
|
+
### Reward Calculation
|
|
166
|
+
|
|
167
|
+
1. Iterate through all prize pools
|
|
168
|
+
2. Get user data based on the pool's metric (volume/pnl)
|
|
169
|
+
3. Estimate user ranking for that metric
|
|
170
|
+
4. Find matching tier and accumulate rewards
|
|
171
|
+
|
|
172
|
+
### Ticket Calculation
|
|
173
|
+
|
|
174
|
+
- **Tiered Mode**: Find the highest tier that matches the user's trading volume
|
|
175
|
+
- **Linear Mode**: Calculate proportionally using `Math.floor(volume / every) * tickets`
|
|
176
|
+
|
|
177
|
+
## Important Notes
|
|
178
|
+
|
|
179
|
+
1. Ranking estimation is based on simplified logic; it's recommended to use real leaderboard data in actual applications
|
|
180
|
+
2. When user trading volume or PnL is 0 or negative, some calculations may return empty results
|
|
181
|
+
3. It's recommended to integrate real API data sources in production environments
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,538 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import react__default, { FC, ReactNode } from 'react';
|
|
3
|
+
import * as _kodiak_finance_orderly_ui from '@kodiak-finance/orderly-ui';
|
|
4
|
+
import { TableSort } from '@kodiak-finance/orderly-ui';
|
|
5
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
type Campaign = {
|
|
8
|
+
title: string;
|
|
9
|
+
description: string;
|
|
10
|
+
image: string;
|
|
11
|
+
startTime: Date | string;
|
|
12
|
+
endTime: Date | string;
|
|
13
|
+
href: string | {
|
|
14
|
+
/** learn more url */
|
|
15
|
+
learnMore: string;
|
|
16
|
+
/** trading url, if provided, will override default trading now button url */
|
|
17
|
+
trading: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Trading leaderboard provider state
|
|
22
|
+
*/
|
|
23
|
+
type TradingLeaderboardState$1 = {
|
|
24
|
+
/** campaigns config, if not provided, will not show campaigns section */
|
|
25
|
+
campaigns?: Campaign[];
|
|
26
|
+
/** background src, it can be a image resource or video resource */
|
|
27
|
+
backgroundSrc?: string;
|
|
28
|
+
href?: {
|
|
29
|
+
/** default trading now button url */
|
|
30
|
+
trading: string;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
type TradingLeaderboardProviderProps$1 = react__default.PropsWithChildren<TradingLeaderboardState$1>;
|
|
34
|
+
|
|
35
|
+
type LeaderboardScriptReturn = ReturnType<typeof useLeaderboardScript>;
|
|
36
|
+
type LeaderboardScriptOptions = {
|
|
37
|
+
backgroundSrc?: string;
|
|
38
|
+
campaigns?: Campaign[];
|
|
39
|
+
};
|
|
40
|
+
declare function useLeaderboardScript(options: LeaderboardScriptOptions): {
|
|
41
|
+
backgroundSrc: string | undefined;
|
|
42
|
+
isVideo: boolean;
|
|
43
|
+
showCampaigns: boolean;
|
|
44
|
+
isMobile: boolean;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
type LeaderboardProps = {
|
|
48
|
+
style?: React.CSSProperties;
|
|
49
|
+
className?: string;
|
|
50
|
+
} & LeaderboardScriptReturn;
|
|
51
|
+
declare const Leaderboard: FC<LeaderboardProps>;
|
|
52
|
+
|
|
53
|
+
type LeaderboardWidgetProps = TradingLeaderboardProviderProps$1 & Pick<LeaderboardProps, "style" | "className">;
|
|
54
|
+
/**
|
|
55
|
+
* @deprecated use LeaderboardPage instead
|
|
56
|
+
* it will be removed in next version
|
|
57
|
+
*/
|
|
58
|
+
declare const LeaderboardWidget: FC<LeaderboardWidgetProps>;
|
|
59
|
+
|
|
60
|
+
type CampaignsWidgetProps = {
|
|
61
|
+
className?: string;
|
|
62
|
+
style?: React.CSSProperties;
|
|
63
|
+
};
|
|
64
|
+
declare const CampaignsWidget: FC<CampaignsWidgetProps>;
|
|
65
|
+
|
|
66
|
+
type CampaignsScriptReturn = ReturnType<typeof useCampaignsScript>;
|
|
67
|
+
type CategorizedCampaigns = {
|
|
68
|
+
ongoing: Campaign[];
|
|
69
|
+
past: Campaign[];
|
|
70
|
+
future: Campaign[];
|
|
71
|
+
};
|
|
72
|
+
type CurrentCampaigns = Campaign & {
|
|
73
|
+
displayTime: string;
|
|
74
|
+
learnMoreUrl: string;
|
|
75
|
+
tradingUrl: string;
|
|
76
|
+
};
|
|
77
|
+
type TEmblaApi = {
|
|
78
|
+
scrollTo?: (index: number) => void;
|
|
79
|
+
};
|
|
80
|
+
type CategoryKey = keyof CategorizedCampaigns;
|
|
81
|
+
declare function useCampaignsScript(): {
|
|
82
|
+
options: {
|
|
83
|
+
label: string;
|
|
84
|
+
value: CategoryKey;
|
|
85
|
+
}[];
|
|
86
|
+
currentCampaigns: {
|
|
87
|
+
displayTime: string;
|
|
88
|
+
learnMoreUrl: string;
|
|
89
|
+
tradingUrl: string;
|
|
90
|
+
title: string;
|
|
91
|
+
description: string;
|
|
92
|
+
image: string;
|
|
93
|
+
startTime: Date | string;
|
|
94
|
+
endTime: Date | string;
|
|
95
|
+
href: string | {
|
|
96
|
+
learnMore: string;
|
|
97
|
+
trading: string;
|
|
98
|
+
};
|
|
99
|
+
}[];
|
|
100
|
+
category: keyof CategorizedCampaigns;
|
|
101
|
+
onCategoryChange: (value: string) => void;
|
|
102
|
+
tradingUrl: string | undefined;
|
|
103
|
+
emblaRef: _kodiak_finance_orderly_ui.EmblaViewportRefType;
|
|
104
|
+
emblaApi: TEmblaApi;
|
|
105
|
+
scrollIndex: number;
|
|
106
|
+
enableScroll: boolean;
|
|
107
|
+
onLearnMore: (campaign: CurrentCampaigns) => void;
|
|
108
|
+
onTradeNow: (campaign: CurrentCampaigns) => void;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
type CampaignsProps = {
|
|
112
|
+
className?: string;
|
|
113
|
+
style?: React.CSSProperties;
|
|
114
|
+
} & CampaignsScriptReturn;
|
|
115
|
+
declare const Campaigns: FC<CampaignsProps>;
|
|
116
|
+
|
|
117
|
+
type TradingData = {
|
|
118
|
+
account_id: string;
|
|
119
|
+
address: string;
|
|
120
|
+
broker_fee: number;
|
|
121
|
+
date: string;
|
|
122
|
+
perp_maker_volume: number;
|
|
123
|
+
perp_taker_volume: number;
|
|
124
|
+
perp_volume: number;
|
|
125
|
+
total_fee: number;
|
|
126
|
+
key?: string;
|
|
127
|
+
};
|
|
128
|
+
type TradingListScriptReturn = ReturnType<typeof useTradingListScript>;
|
|
129
|
+
declare const FilterDays$1: readonly [7, 14, 30, 90];
|
|
130
|
+
type TFilterDays$1 = (typeof FilterDays$1)[number];
|
|
131
|
+
type DateRange$1 = {
|
|
132
|
+
from?: Date;
|
|
133
|
+
to?: Date;
|
|
134
|
+
};
|
|
135
|
+
declare function useTradingListScript(): {
|
|
136
|
+
pagination: _kodiak_finance_orderly_ui.PaginationMeta;
|
|
137
|
+
dateRange: DateRange$1;
|
|
138
|
+
filterDay: 30 | 7 | 14 | 90 | null;
|
|
139
|
+
updateFilterDay: (day: TFilterDays$1) => void;
|
|
140
|
+
filterItems: any;
|
|
141
|
+
onFilter: (filter: {
|
|
142
|
+
name: string;
|
|
143
|
+
value: any;
|
|
144
|
+
}) => void;
|
|
145
|
+
initialSort: TableSort;
|
|
146
|
+
onSort: (sort?: TableSort) => void;
|
|
147
|
+
dataSource: TradingData[];
|
|
148
|
+
isLoading: boolean;
|
|
149
|
+
searchValue: string;
|
|
150
|
+
onSearchValueChange: (value: string) => void;
|
|
151
|
+
clearSearchValue: () => void;
|
|
152
|
+
isMobile: boolean;
|
|
153
|
+
sentinelRef: react.MutableRefObject<HTMLDivElement | null>;
|
|
154
|
+
dataList: TradingData[];
|
|
155
|
+
address: string | undefined;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
type TradingListProps = {
|
|
159
|
+
style?: React.CSSProperties;
|
|
160
|
+
className?: string;
|
|
161
|
+
} & TradingListScriptReturn;
|
|
162
|
+
declare const TradingList: FC<TradingListProps>;
|
|
163
|
+
|
|
164
|
+
type TradingListWidgetProps = Pick<TradingListProps, "style" | "className">;
|
|
165
|
+
/**
|
|
166
|
+
* @deprecated use TradingListPage instead
|
|
167
|
+
* it will be removed in next version
|
|
168
|
+
*/
|
|
169
|
+
declare const TradingListWidget: FC<TradingListWidgetProps>;
|
|
170
|
+
|
|
171
|
+
type RankingColumnFields = "rank" | "address" | "volume" | "pnl" | "rewards";
|
|
172
|
+
|
|
173
|
+
type ListStyle = "disc" | "decimal" | "none" | "circle" | "square" | "decimal-leading-zero" | "lower-alpha" | "upper-alpha" | "lower-roman" | "upper-roman";
|
|
174
|
+
type DescriptionItem = {
|
|
175
|
+
content: string;
|
|
176
|
+
type: "markdown" | "text" | "image";
|
|
177
|
+
alt?: string;
|
|
178
|
+
className?: string;
|
|
179
|
+
listStyle?: ListStyle;
|
|
180
|
+
listClassName?: string;
|
|
181
|
+
children?: DescriptionItem[];
|
|
182
|
+
};
|
|
183
|
+
type DescriptionConfig = {
|
|
184
|
+
listStyle?: ListStyle;
|
|
185
|
+
listClassName?: string;
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
declare enum CampaignTagEnum {
|
|
189
|
+
ONGOING = "ongoing",
|
|
190
|
+
COMING = "coming",
|
|
191
|
+
ENDED = "ended",
|
|
192
|
+
EXCLUSIVE = "exclusive"
|
|
193
|
+
}
|
|
194
|
+
interface CampaignStatistics {
|
|
195
|
+
total_participants?: number;
|
|
196
|
+
total_volume?: number;
|
|
197
|
+
}
|
|
198
|
+
interface PrizePoolTier {
|
|
199
|
+
position?: number;
|
|
200
|
+
position_range?: [number, number];
|
|
201
|
+
amount: number;
|
|
202
|
+
}
|
|
203
|
+
interface PrizePool {
|
|
204
|
+
pool_id: string;
|
|
205
|
+
label: string;
|
|
206
|
+
total_prize: number;
|
|
207
|
+
currency: string;
|
|
208
|
+
metric: "volume" | "pnl";
|
|
209
|
+
tiers: PrizePoolTier[];
|
|
210
|
+
volume_limit?: number;
|
|
211
|
+
}
|
|
212
|
+
interface TicketTierRule {
|
|
213
|
+
value: number;
|
|
214
|
+
tickets: number;
|
|
215
|
+
}
|
|
216
|
+
interface TicketLinearRule {
|
|
217
|
+
every: number;
|
|
218
|
+
tickets: number;
|
|
219
|
+
}
|
|
220
|
+
interface TicketRules {
|
|
221
|
+
total_prize: number;
|
|
222
|
+
currency: string;
|
|
223
|
+
metric: "volume" | "pnl";
|
|
224
|
+
mode: "tiered" | "linear";
|
|
225
|
+
tiers?: TicketTierRule[];
|
|
226
|
+
linear?: TicketLinearRule;
|
|
227
|
+
}
|
|
228
|
+
interface CampaignConfig {
|
|
229
|
+
campaign_id: number | string;
|
|
230
|
+
title: string;
|
|
231
|
+
subtitle?: string;
|
|
232
|
+
description: string;
|
|
233
|
+
content?: ReactNode;
|
|
234
|
+
classNames?: {
|
|
235
|
+
container?: string;
|
|
236
|
+
topContainer?: string;
|
|
237
|
+
title?: string;
|
|
238
|
+
description?: string;
|
|
239
|
+
descriptionContainer?: string;
|
|
240
|
+
};
|
|
241
|
+
register_time?: string;
|
|
242
|
+
start_time: string;
|
|
243
|
+
end_time: string;
|
|
244
|
+
reward_distribution_time?: string;
|
|
245
|
+
volume_scope?: string | string[];
|
|
246
|
+
referral_codes?: string[] | string;
|
|
247
|
+
prize_pools?: PrizePool[];
|
|
248
|
+
tiered_prize_pools?: Array<PrizePool[]>;
|
|
249
|
+
ticket_rules?: TicketRules;
|
|
250
|
+
image?: string;
|
|
251
|
+
rule_url?: string;
|
|
252
|
+
rule_config?: {
|
|
253
|
+
action?: "scroll" | "click";
|
|
254
|
+
};
|
|
255
|
+
trading_url?: string;
|
|
256
|
+
trading_config?: {
|
|
257
|
+
format?: string;
|
|
258
|
+
};
|
|
259
|
+
href?: string;
|
|
260
|
+
hide_arena?: boolean;
|
|
261
|
+
hide_rewards?: boolean;
|
|
262
|
+
hide_estimated_rewards?: boolean;
|
|
263
|
+
highlight_pool_id?: string;
|
|
264
|
+
user_account_label?: string;
|
|
265
|
+
rule?: {
|
|
266
|
+
rule: DescriptionItem[];
|
|
267
|
+
terms: DescriptionItem[];
|
|
268
|
+
ruleConfig?: DescriptionConfig;
|
|
269
|
+
};
|
|
270
|
+
leaderboard_config?: LeaderboardConfig;
|
|
271
|
+
emphasisConfig?: {
|
|
272
|
+
subtitle: string;
|
|
273
|
+
walletConnect: {
|
|
274
|
+
title: string;
|
|
275
|
+
description: string;
|
|
276
|
+
};
|
|
277
|
+
hideConnectWallet: boolean;
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
interface LeaderboardConfig {
|
|
281
|
+
use_general_leaderboard?: boolean;
|
|
282
|
+
exclude_leaderboard_columns?: RankingColumnFields[];
|
|
283
|
+
week_one_addresses?: string[];
|
|
284
|
+
}
|
|
285
|
+
interface UserData {
|
|
286
|
+
rank?: number | string;
|
|
287
|
+
pnl: number;
|
|
288
|
+
total_participants?: number;
|
|
289
|
+
volume: number;
|
|
290
|
+
referral_code?: string;
|
|
291
|
+
}
|
|
292
|
+
type CampaignStatsDetailsResponse = {
|
|
293
|
+
broker_id: string;
|
|
294
|
+
user_count: number;
|
|
295
|
+
volume: number;
|
|
296
|
+
symbol: string;
|
|
297
|
+
}[];
|
|
298
|
+
type CampaignStatsResponse = {
|
|
299
|
+
sign_up_count: number;
|
|
300
|
+
user_count: number;
|
|
301
|
+
volume: number;
|
|
302
|
+
updated_time: number;
|
|
303
|
+
};
|
|
304
|
+
type UserCampaignsResponse = {
|
|
305
|
+
id: string;
|
|
306
|
+
register_time: number;
|
|
307
|
+
}[];
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Trading leaderboard provider state
|
|
311
|
+
*/
|
|
312
|
+
type TradingLeaderboardState = {
|
|
313
|
+
/** campaigns config, if not provided, will not show campaigns section */
|
|
314
|
+
campaigns?: CampaignConfig[];
|
|
315
|
+
/** background src, it can be a image resource or video resource */
|
|
316
|
+
backgroundSrc?: string;
|
|
317
|
+
href?: {
|
|
318
|
+
/** default trading now button url */
|
|
319
|
+
trading: string;
|
|
320
|
+
};
|
|
321
|
+
currentCampaignId: string | number;
|
|
322
|
+
currentCampaign?: CampaignConfig;
|
|
323
|
+
onCampaignChange: (campaignId: string | number) => void;
|
|
324
|
+
/** leaderboard user data, it will be used to calculate the rewards */
|
|
325
|
+
userData?: UserData;
|
|
326
|
+
/** set leaderboard user data */
|
|
327
|
+
setUserData?: (userdata: UserData) => void;
|
|
328
|
+
/** campaign ranking list updated time */
|
|
329
|
+
updatedTime?: number;
|
|
330
|
+
/** set snapshot time */
|
|
331
|
+
setUpdatedTime?: (updatedTime?: number) => void;
|
|
332
|
+
/** custom data, if use this, you can full control the data */
|
|
333
|
+
dataAdapter?: (info: {
|
|
334
|
+
page: number;
|
|
335
|
+
pageSize: number;
|
|
336
|
+
}) => {
|
|
337
|
+
loading: boolean;
|
|
338
|
+
dataSource?: any[];
|
|
339
|
+
dataList?: any[];
|
|
340
|
+
userData?: any;
|
|
341
|
+
updatedTime?: number;
|
|
342
|
+
meta?: {
|
|
343
|
+
total: number;
|
|
344
|
+
current_page: number;
|
|
345
|
+
records_per_page: number;
|
|
346
|
+
};
|
|
347
|
+
};
|
|
348
|
+
campaignDateRange?: {
|
|
349
|
+
start_time: Date | string;
|
|
350
|
+
end_time: Date | string;
|
|
351
|
+
};
|
|
352
|
+
statistics?: CampaignStatistics;
|
|
353
|
+
setStatistics?: (statistics: CampaignStatistics) => void;
|
|
354
|
+
};
|
|
355
|
+
/**
|
|
356
|
+
* Trading leaderboard context
|
|
357
|
+
*/
|
|
358
|
+
declare const TradingLeaderboardContext: react__default.Context<TradingLeaderboardState>;
|
|
359
|
+
type TradingLeaderboardProviderProps = Pick<TradingLeaderboardState, "campaigns" | "href" | "backgroundSrc" | "dataAdapter"> & {
|
|
360
|
+
campaignId?: string | number;
|
|
361
|
+
onCampaignChange?: (campaignId: string | number) => void;
|
|
362
|
+
};
|
|
363
|
+
declare const TradingLeaderboardProvider: react__default.FC<react__default.PropsWithChildren<TradingLeaderboardProviderProps>>;
|
|
364
|
+
declare const useTradingLeaderboardContext: () => TradingLeaderboardState;
|
|
365
|
+
|
|
366
|
+
type CampaignRankingData = {
|
|
367
|
+
broker_id: string;
|
|
368
|
+
account_id: string;
|
|
369
|
+
address: string;
|
|
370
|
+
volume: number;
|
|
371
|
+
pnl: number;
|
|
372
|
+
total_deposit_amount: number;
|
|
373
|
+
total_withdrawal_amount: number;
|
|
374
|
+
start_account_value: number;
|
|
375
|
+
end_account_value: number;
|
|
376
|
+
key?: string;
|
|
377
|
+
rank?: number | string;
|
|
378
|
+
rewards?: {
|
|
379
|
+
amount: number;
|
|
380
|
+
currency: string;
|
|
381
|
+
};
|
|
382
|
+
};
|
|
383
|
+
type CampaignRankingScriptOptions = {
|
|
384
|
+
campaignId: number | string;
|
|
385
|
+
sortKey?: "volume" | "pnl";
|
|
386
|
+
};
|
|
387
|
+
declare function useCampaignRankingScript(options: CampaignRankingScriptOptions): {
|
|
388
|
+
pagination: _kodiak_finance_orderly_ui.PaginationMeta;
|
|
389
|
+
initialSort: TableSort;
|
|
390
|
+
dataSource: any[] | undefined;
|
|
391
|
+
isLoading: boolean | undefined;
|
|
392
|
+
isMobile: boolean;
|
|
393
|
+
sentinelRef: react.MutableRefObject<HTMLDivElement | null>;
|
|
394
|
+
dataList: any[] | undefined;
|
|
395
|
+
address: string | undefined;
|
|
396
|
+
};
|
|
397
|
+
|
|
398
|
+
type DateRange = {
|
|
399
|
+
from?: Date;
|
|
400
|
+
to?: Date;
|
|
401
|
+
label?: string;
|
|
402
|
+
};
|
|
403
|
+
declare enum LeaderboardTab {
|
|
404
|
+
Volume = "volume",
|
|
405
|
+
Pnl = "pnl"
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
type GeneralRankingData = {
|
|
409
|
+
account_id: string;
|
|
410
|
+
address: string;
|
|
411
|
+
broker_fee: number;
|
|
412
|
+
date: string;
|
|
413
|
+
perp_maker_volume: number;
|
|
414
|
+
perp_taker_volume: number;
|
|
415
|
+
perp_volume: number;
|
|
416
|
+
realized_pnl: number;
|
|
417
|
+
total_fee: number;
|
|
418
|
+
key?: string;
|
|
419
|
+
rank?: number | string;
|
|
420
|
+
volume?: number;
|
|
421
|
+
pnl?: number;
|
|
422
|
+
};
|
|
423
|
+
type GeneralRankingScriptReturn = ReturnType<typeof useGeneralRankingScript>;
|
|
424
|
+
type GeneralRankingScriptOptions = {
|
|
425
|
+
dateRange?: DateRange | null;
|
|
426
|
+
address?: string;
|
|
427
|
+
sortKey?: "perp_volume" | "realized_pnl";
|
|
428
|
+
};
|
|
429
|
+
declare function useGeneralRankingScript(options?: GeneralRankingScriptOptions): {
|
|
430
|
+
pagination: _kodiak_finance_orderly_ui.PaginationMeta;
|
|
431
|
+
initialSort: TableSort;
|
|
432
|
+
onSort: (sort?: TableSort) => void;
|
|
433
|
+
dataSource: any[];
|
|
434
|
+
isLoading: boolean;
|
|
435
|
+
isMobile: boolean;
|
|
436
|
+
sentinelRef: react.MutableRefObject<HTMLDivElement | null>;
|
|
437
|
+
dataList: any[];
|
|
438
|
+
address: string | undefined;
|
|
439
|
+
};
|
|
440
|
+
|
|
441
|
+
type RankingData = GeneralRankingData | CampaignRankingData;
|
|
442
|
+
type RankingProps = {
|
|
443
|
+
style?: React.CSSProperties;
|
|
444
|
+
className?: string;
|
|
445
|
+
fields: RankingColumnFields[];
|
|
446
|
+
} & Omit<GeneralRankingScriptReturn, "dataList" | "dataSource"> & {
|
|
447
|
+
dataList: RankingData[];
|
|
448
|
+
dataSource: RankingData[];
|
|
449
|
+
};
|
|
450
|
+
declare const Ranking: FC<RankingProps>;
|
|
451
|
+
|
|
452
|
+
type GeneralRankingWidgetProps = Pick<RankingProps, "style" | "className" | "fields"> & GeneralRankingScriptOptions;
|
|
453
|
+
declare const GeneralRankingWidget: FC<GeneralRankingWidgetProps>;
|
|
454
|
+
|
|
455
|
+
type CampaignRankingWidgetProps = Pick<RankingProps, "style" | "className" | "fields"> & CampaignRankingScriptOptions;
|
|
456
|
+
declare const CampaignRankingWidget: FC<CampaignRankingWidgetProps>;
|
|
457
|
+
|
|
458
|
+
type WeeklyDateRange = {
|
|
459
|
+
from: Date;
|
|
460
|
+
to: Date;
|
|
461
|
+
label: string;
|
|
462
|
+
};
|
|
463
|
+
|
|
464
|
+
type GeneralLeaderboardScriptReturn = ReturnType<typeof useGeneralLeaderboardScript>;
|
|
465
|
+
declare const FilterDays: readonly [7, 14, 30, 90];
|
|
466
|
+
type TFilterDays = (typeof FilterDays)[number];
|
|
467
|
+
type GeneralLeaderboardScriptOptions = {
|
|
468
|
+
campaignDateRange?: {
|
|
469
|
+
start_time: Date | string;
|
|
470
|
+
end_time: Date | string;
|
|
471
|
+
};
|
|
472
|
+
};
|
|
473
|
+
declare function useGeneralLeaderboardScript(options?: GeneralLeaderboardScriptOptions): {
|
|
474
|
+
activeTab: LeaderboardTab;
|
|
475
|
+
onTabChange: react.Dispatch<react.SetStateAction<LeaderboardTab>>;
|
|
476
|
+
useCampaignDateRange: boolean;
|
|
477
|
+
weeklyRanges: WeeklyDateRange[];
|
|
478
|
+
currentOrAllTimeRange: WeeklyDateRange | undefined;
|
|
479
|
+
searchValue: string;
|
|
480
|
+
onSearchValueChange: (value: string) => void;
|
|
481
|
+
clearSearchValue: () => void;
|
|
482
|
+
filterItems: any;
|
|
483
|
+
onFilter: (filter: {
|
|
484
|
+
name: string;
|
|
485
|
+
value: any;
|
|
486
|
+
}) => void;
|
|
487
|
+
dateRange: DateRange;
|
|
488
|
+
filterDay: 30 | 7 | 14 | 90 | null;
|
|
489
|
+
updateFilterDay: (day: TFilterDays) => void;
|
|
490
|
+
setDateRange: react.Dispatch<react.SetStateAction<DateRange>>;
|
|
491
|
+
};
|
|
492
|
+
|
|
493
|
+
type GeneralLeaderboardProps = {
|
|
494
|
+
style?: React.CSSProperties;
|
|
495
|
+
className?: string;
|
|
496
|
+
campaignDateRange?: {
|
|
497
|
+
start_time: Date | string;
|
|
498
|
+
end_time: Date | string;
|
|
499
|
+
};
|
|
500
|
+
} & GeneralLeaderboardScriptReturn;
|
|
501
|
+
declare const GeneralLeaderboard: FC<GeneralLeaderboardProps>;
|
|
502
|
+
|
|
503
|
+
type GeneralLeaderboardWidgetProps = Pick<GeneralLeaderboardProps, "style" | "className" | "campaignDateRange">;
|
|
504
|
+
declare const GeneralLeaderboardWidget: FC<GeneralLeaderboardWidgetProps>;
|
|
505
|
+
|
|
506
|
+
type CampaignLeaderboardScriptReturn = ReturnType<typeof useCampaignLeaderboardScript>;
|
|
507
|
+
declare function useCampaignLeaderboardScript(): {
|
|
508
|
+
activeTab: LeaderboardTab;
|
|
509
|
+
onTabChange: react.Dispatch<react.SetStateAction<LeaderboardTab>>;
|
|
510
|
+
excludeColumns: RankingColumnFields[];
|
|
511
|
+
};
|
|
512
|
+
|
|
513
|
+
type CampaignLeaderboardProps = {
|
|
514
|
+
style?: React.CSSProperties;
|
|
515
|
+
className?: string;
|
|
516
|
+
campaignId: number | string;
|
|
517
|
+
} & CampaignLeaderboardScriptReturn;
|
|
518
|
+
declare const CampaignLeaderboard: FC<CampaignLeaderboardProps>;
|
|
519
|
+
|
|
520
|
+
type CampaignLeaderboardWidgetProps = Pick<CampaignLeaderboardProps, "style" | "className" | "campaignId">;
|
|
521
|
+
declare const CampaignLeaderboardWidget: FC<CampaignLeaderboardWidgetProps>;
|
|
522
|
+
|
|
523
|
+
type LeaderboardPageProps = GeneralLeaderboardWidgetProps & TradingLeaderboardProviderProps & {
|
|
524
|
+
style?: React.CSSProperties;
|
|
525
|
+
className?: string;
|
|
526
|
+
};
|
|
527
|
+
declare const LeaderboardPage: FC<LeaderboardPageProps>;
|
|
528
|
+
type LeaderboardSectionProps = {
|
|
529
|
+
style?: React.CSSProperties;
|
|
530
|
+
className?: string;
|
|
531
|
+
};
|
|
532
|
+
declare const LeaderboardSection: FC<LeaderboardSectionProps>;
|
|
533
|
+
declare const LeaderboardTitle: (props: {
|
|
534
|
+
title: ReactNode;
|
|
535
|
+
isMobile?: boolean;
|
|
536
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
537
|
+
|
|
538
|
+
export { type Campaign, type CampaignConfig, CampaignLeaderboard, type CampaignLeaderboardProps, CampaignLeaderboardWidget, type CampaignLeaderboardWidgetProps, CampaignRankingWidget, type CampaignRankingWidgetProps, type CampaignStatistics, type CampaignStatsDetailsResponse, type CampaignStatsResponse, CampaignTagEnum, Campaigns, type CampaignsProps, CampaignsWidget, GeneralLeaderboard, type GeneralLeaderboardProps, GeneralLeaderboardWidget, type GeneralLeaderboardWidgetProps, GeneralRankingWidget, type GeneralRankingWidgetProps, Leaderboard, type LeaderboardConfig, LeaderboardPage, type LeaderboardPageProps, type LeaderboardProps, LeaderboardSection, LeaderboardTitle, LeaderboardWidget, type LeaderboardWidgetProps, type PrizePool, type PrizePoolTier, Ranking, type RankingProps, type TicketLinearRule, type TicketRules, type TicketTierRule, TradingLeaderboardContext, TradingLeaderboardProvider, type TradingLeaderboardProviderProps, type TradingLeaderboardState, TradingList, type TradingListProps, TradingListWidget, type TradingListWidgetProps, type UserCampaignsResponse, type UserData, useCampaignLeaderboardScript, useCampaignRankingScript, useCampaignsScript, useGeneralLeaderboardScript, useGeneralRankingScript, useLeaderboardScript, useTradingLeaderboardContext, useTradingListScript };
|